
#include <iostream>

#include <cppunit/extensions/HelperMacros.h>

#include "../../tuxitty/src/MsnContact.h"

class MsnContactTest : public CppUnit::TestFixture
{
	CPPUNIT_TEST_SUITE( MsnContactTest );

	CPPUNIT_TEST( TestIsInList );
	CPPUNIT_TEST( TestAddList );
	CPPUNIT_TEST( TestRemoveList );

	CPPUNIT_TEST( TestAddGroup );
	CPPUNIT_TEST( TestRemoveGroup );

	CPPUNIT_TEST_SUITE_END();

public:
	MsnContact* contact;

	void setUp(){
		contact = new MsnContact();
		contact->SetListNumber(FORWARD + ALLOWED + REVERSED);
	}

	void tearDown(){
		delete contact;
	}

	void TestIsInList()
	{				
		CPPUNIT_ASSERT(contact->IsInList(FORWARD));
		CPPUNIT_ASSERT(contact->IsInList(ALLOWED));

		CPPUNIT_ASSERT(contact->IsInList(REVERSED));

		CPPUNIT_ASSERT(!contact->IsInList(BLOCKED));
	}

	void TestAddList()
	{
		contact->AddList(BLOCKED);
		CPPUNIT_ASSERT(contact->IsInList(BLOCKED));
	}

	void TestRemoveList()
	{
		contact->RemoveList(FORWARD);
		CPPUNIT_ASSERT(!contact->IsInList(FORWARD));
	}

	void TestAddGroup()
	{
		contact->AddGroup(_T("1"));
		CPPUNIT_ASSERT(_T("1") == contact->GetGroupString());

		contact->AddGroup(_T("2"));
		CPPUNIT_ASSERT(_T("1,2") == contact->GetGroupString());

	}

	void TestRemoveGroup()
	{
		contact->SetGroupString(_T("1,2,3"));

		contact->RemoveGroup(_T("2"));
		CPPUNIT_ASSERT(_T("1,3") == contact->GetGroupString());

		contact->RemoveGroup(_T("3"));
		CPPUNIT_ASSERT(_T("1") == contact->GetGroupString());
	
	}

};


CPPUNIT_TEST_SUITE_REGISTRATION(MsnContactTest);
